﻿<UserControl x:Class="MCDA.AddDataView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" mc:Ignorable="d" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:model="clr-namespace:MCDA.Model"
             d:DesignHeight="500" d:DesignWidth="400">
<!-- RadioButton and Checkbox do not align with the text. This is probably a font size problem. Even ArcMap controls look strange, thus I do not invest more time solving this "problem"-->
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid>
            <TreeView ItemsSource="{Binding Features}" >
                <TreeView.ItemContainerStyle>
                    <Style TargetType="{x:Type TreeViewItem}">
                        <Setter Property="IsExpanded" Value="True" />
                    </Style>
                </TreeView.ItemContainerStyle>
                <TreeView.Resources>
                    <HierarchicalDataTemplate ItemsSource="{Binding Fields}" DataType="{x:Type model:Feature}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <RadioButton Grid.Column="0" Name="IsSelectedRadioButton" ToolTipService.ShowOnDisabled="True" IsChecked="{Binding Path=IsSelected, Mode=TwoWay}" GroupName="selectedFeatureGroup" IsEnabled="{Binding Path=IsSuitableForMCDA, Mode=OneWay}">
                            <RadioButton.Style>
                                <Style TargetType="RadioButton">
                                    <!--<Setter Property="Content" Value="{Binding Path=FeatureName}" />-->
                                    <Style.Triggers>
                                        <DataTrigger Binding="{Binding Path=IsSuitableForMCDA}" Value="false">
                                            <Setter Property="ToolTip" Value="{Binding Path=NotSuitableForMCDAReason, Mode=OneWay}" />
                                        </DataTrigger>  
                                        <!--<DataTrigger Binding="{Binding Path=IsSuitableForMCDA}" Value="false">
                                            <Setter Property="Content" >
                                                <Setter.Value>
                                                    <MultiBinding StringFormat="\{0}   reason: {1}">
                                                        <Binding  Path="FeatureName" />
                                                        <Binding  Path="NotSuitableForMCDAReason" />
                                                    </MultiBinding>
                                                </Setter.Value>
                                            </Setter>
                                        </DataTrigger>-->
                                    </Style.Triggers>
                                </Style>
                            </RadioButton.Style>
                                <Label Grid.Column="1" Content="{Binding Path=FeatureName}" IsEnabled="{Binding Path=IsSuitableForMCDA}" />
                        </RadioButton>
                            <Label Grid.Column="2">
                                <Label.Style>
                                    <Style TargetType="Label">
                                        <!--<Setter Property="Content" Value="{Binding Path=FeatureName}" />-->
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Path=IsSuitableForMCDA}" Value="false">
                                                <Setter Property="Content" Value="{Binding Path=NotSuitableForMCDAReason, Mode=OneWay}" />
                                            </DataTrigger>                                          
                                        </Style.Triggers>
                                    </Style>
                                </Label.Style>
                            </Label>
                        </Grid>
                    </HierarchicalDataTemplate>
                    <DataTemplate DataType="{x:Type model:Field}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <CheckBox Grid.Column="0" HorizontalContentAlignment="Stretch" Name="CriteriaCheckBox" ToolTipService.ShowOnDisabled="True" IsChecked="{Binding Path=IsSelected, Mode=TwoWay}" IsEnabled="{Binding Path=IsSuitableForMCDA, Mode=OneWay}">
                            <CheckBox.Style>
                                <Style TargetType="CheckBox">
                                    <!--<Setter Property="Content" Value="{Binding Path=FieldName}"/>-->
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Path=IsSuitableForMCDA}" Value="false">
                                            <Setter Property="ToolTip" Value="{Binding Path=NotSuitableForMCDAReason, Mode=OneWay}" />
                                        </DataTrigger>
                                    </Style.Triggers>
                                </Style>
                            </CheckBox.Style>
                        </CheckBox>
                            <Label Grid.Column="1" Content="{Binding Path=FieldName}" IsEnabled="{Binding Path=IsSuitableForMCDA}" />
                            <Label Grid.Column="2">
                                <Label.Style>
                                    <Style TargetType="Label">
                                        <Style.Triggers>
                                            <DataTrigger Binding="{Binding Path=IsSuitableForMCDA}" Value="false">
                                                <Setter Property="Content" Value="{Binding Path=NotSuitableForMCDAReason, Mode=OneWay}" />
                                            </DataTrigger>
                                        </Style.Triggers>
                                    </Style>
                                </Label.Style>
                            </Label>
                        </Grid>
                    </DataTemplate >
                </TreeView.Resources>
            </TreeView>
        </Grid>
    </Grid>
</UserControl>
